/*
Simple Forum Auto Poster.
Copyright (C) 2011 Gianni Van Hoecke.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package domain.plugin.base;

import domain.settings.Settings;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Gianni Van Hoecke <gianni.vh@gmail.com>
 *
 * The base of any plugin.
 *
 * <b>If you're a plugin developer, you shouldn't use this abstract class as it
 * doesn't provide any interaction possibilities to the user.
 * Use BasicPlugin instead, that class returns a JMenu that you can use to
 * interact with the user.</b>
 *
 * You should only use this class when user interaction is not needed.
 * 
 * @see BasicPlugin
 */
public abstract class Plugin
{
    public static Interaction interaction;
    public static final Logger logger = Logger.getLogger(Settings.APP_NAME);

    /**
     * If the plugin needs to log something, please use this logger.
     * The messages will be shown by the program.
     * @return The logger of the program.
     */
    public static Logger getLogger()
    {
        return logger;
    }

    /**
     * This method is final and thus can't be overridden.
     * @return The interaction object.
     */
    public final Interaction getInteraction()
    {
        return interaction;
    }

    /**
     * Sets the interaction. This method will be called automatically by the program.
     * This method is final and thus can't be overridden.
     * @param interaction The non-null interaction object.
     */
    public final void load(Interaction i) throws NullPointerException
    {
        if(i == null)
            throw new NullPointerException("Interaction object can't be null");
        
        interaction = i;

        logger.log(Level.INFO, "Plugin {0} {1} by {2} loaded!", new Object[]{getName(), getVersion(), getAuthor()});
    }

    /**
     * @return The type of implementation of the plugin.
     */
    public abstract PluginType getType();

    /**
     * @return The name of the plugin.
     */
    public abstract String getName();

    /**
     * @return The author of the plugin.
     */
    public abstract String getAuthor();

    /**
     * @return The version of the plugin.
     */
    public abstract String getVersion();

    /**
     * @return The description of the plugin.
     */
    public abstract String getDescription();
}